package com.hnkywl.sts.action.flow;

import com.hnkywl.sts.entity.flow.FlowConfigure;
import com.hnkywl.sts.service.flow.LcpzService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created with IntelliJ IDEA.
 * User: lenovo
 * Date: 13-6-16
 * Time: 下午5:20
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/flow/lcpz")
public class LcpzAction extends SimpleActionSupport {
    private LcpzService lcpzService;
    private FlowConfigure lcpz;
    //查询条件
    private String name;
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows;
    private Long lcpzId;
    private Boolean flowStart;

    /**
     * 流程配置列表查询
     */
    @Action("lcpzList")
    public void lcpzList() {
        this.renderJson(this.lcpzService.findAllLcpz(name,page, rows));
    }

    /**
     * 开启
     */
    @Action("kq")
    public void kq() {
        try {
            lcpzService.changeStatus(lcpzId, flowStart);
            renderText("{\"statusCode\":\"200\", \"message\":\"开启成功！\", \"operationType\":\"check\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    /**
     * 开启
     */
    @Action("gb")
    public void gb() {
        try {
            lcpzService.changeStatus(lcpzId, flowStart);
            renderText("{\"statusCode\":\"200\", \"message\":\"关闭成功！\", \"operationType\":\"check\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }
    //===========getter=======setter=============

    public Boolean getFlowStart() {
        return flowStart;
    }

    public void setFlowStart(Boolean flowStart) {
        this.flowStart = flowStart;
    }

    public FlowConfigure getLcpz() {
        return lcpz;
    }

    public void setLcpz(FlowConfigure lcpz) {
        this.lcpz = lcpz;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public Long getLcpzId() {
        return lcpzId;
    }

    public void setLcpzId(Long lcpzId) {
        this.lcpzId = lcpzId;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    @Autowired
    public void setLcpzService(LcpzService lcpzService) {
        this.lcpzService = lcpzService;
    }
}
